package utils

import (
	"fmt"
	"time"
)

type Response struct {
	Code int         `json:"ErrCode"`
	Msg  string      `json:"ErrMsg"`
	Data interface{} `json:"Data"`
}

var now = time.Now().Format("2006-01-02 15:04:05")

var (
	// err
	RequestParamsErr = &Response{Code: 1, Msg: "", Data: nil}
	InnerParamsErr   = &Response{Code: 1, Msg: "", Data: nil}

	// success
	RequestSuccess = &Response{Code: 0, Msg: "", Data: nil}
)

type UpdateRecentUseTimeRequest struct {
	User       string `form:"user" json:"user" `
	DeviceName string `form:"deviceName" json:"deviceName"`
}

func (d *UpdateRecentUseTimeRequest) ParamsVerify() error {
	if len(d.User) > 20 || len(d.User) == 0 {
		return fmt.Errorf("user parameter error")
	}
	if len(d.DeviceName) > 100 || len(d.DeviceName) == 0 {
		return fmt.Errorf("deviceName parameter error")
	}
	return nil
}
